package com.zyw.weibo.ui.support;

import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import cn.emagsoftware.ui.adapterview.AsyncDataExecutor;
import cn.emagsoftware.ui.adapterview.DataHolder;

import com.zyw.weibo.data.CommentToMe;
import com.zyw.weibo.data.remote.NetEngine;
import com.zyw.weibo.data.remote.NetOperatingManager;

public class CommentToMeAsyncDataExecutor extends AsyncDataExecutor {
	
	protected Context context = null;
	
	public CommentToMeAsyncDataExecutor(Context context){
		super(1, 1);
		this.context = context;
	}
	
	@Override
	public void onExecute(List<Integer> arg0, List<DataHolder> arg1, List<Integer> arg2) throws Exception {
		// TODO Auto-generated method stub
		DataHolder holder = arg1.get(0);
		String selfpicture = ((CommentToMe)holder.getData()).selfpicture;
		String picUrl = NetOperatingManager.URL_HOST + selfpicture;
		byte[] data = NetEngine.requestImage(context, picUrl);
		Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
		if(bitmap != null) holder.setAsyncData(0, new BitmapDrawable(bitmap));
	}
	
}
